#pragma once

#include "IReferenceCounter.h"
#include "Sol9Types.h"

namespace sol9
{
namespace util
{

	class TimeManager;

	class Timer : public IReferenceCounter
	{
	private:
		u32 m_nTime;
		bool m_bWorked;

		friend TimeManager;

	public:
		Timer(bool bImmediately = false);
		explicit Timer(u32 nTime);
		~Timer();

		void begin(bool bReset = false);
		void end();
		void reset();
		void kill();

		Timer operator+(const Timer& other) const;
		Timer operator+(const u32 time) const;

		Timer& operator+=(const Timer& other);
		Timer& operator+=(const u32 time);

		Timer operator-(const Timer& other) const;
		Timer operator-(const u32 time) const;

		Timer& operator-=(const Timer& other);
		Timer& operator-=(const u32 time);

		bool operator<(const Timer& other) const;
		bool operator>(const Timer& other) const;

		operator u32() const;

		bool isWorked();

	private:
		virtual void _tick();
	};

} // namespace util
} // namespace sol9